import requests
import execjs


session = requests.Session()

with open('./main.js', 'r', encoding='utf-8') as f:
    js_code = f.read()
js_comp = execjs.compile(js_code)
cookies = {
    "sessionid": "",
}
headers2 = {

}
FgBA = 0
answer = 0
a = js_comp.call("get_m",FgBA)
exit()
for i in range(1, 101):
    data = {
        "page": i
    }
    params={
        "m": js_comp.call("get_m",FgBA)
    }
    url = "https://www.python-spider.com/api/challenge5"
    r = session.post(url, headers=headers2,cookies=cookies, data=data,params=params)
    result = r.json()['data']
    k = r.json()['k']
    print(result)
    FgBA = int(k["k"].split('|')[1])
    print(FgBA)
    for item in result:
        answer += int(item['value'])